﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------


namespace Math.Compiler.Expressions
{

    using Classes;
    using System;

    internal class VariableReference : MathExpression
    {
        private Variable _cell;

        /// <summary>
        /// Gets the id.
        /// </summary>
        /// <value>The id.</value>
        public int Id
        {
            get
            {
                return _cell.Id;
            }
        }

        public VariableReference(string name)
        {
            _cell = Variable.Load(name);
        }

        public bool HasExpression
        {
            get
            {
                return _cell.HasExpression;
            }
        }

        public override double Eval()
        {
            _cell.Eval();
            return _cell.Double;
        }

        public Variable Variable
        {
            get
            {
                return _cell;
            }
        }

#if DEBUG
        public override string ToString()
        {
            return _cell.ToString();
        }
#endif
    }
}
